package com.tianpengtech.admin.notice;

import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.tianpengtech.admin.IAdminOpt;
import com.tianpengtech.common.util.SendSmsMsg;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;


/**
 * 路由配置地址：add("/admin/notice", SMSNoticeController.class, "/admin/notice");
 *
 */
//@Before(InitInterceptor.class)
//@RequiresAuthentication
public class SMSNoticeController extends Controller {
    private IAdminOpt opt = new SMSNoticeServiceImpl();


    public void smsNotice(){
        renderTemplate("sms-notice.html");
    }

    //发送短信
    public void sendSMSNotice(){
        String phone = getPara("phone");
        String templateCode = getPara("templateCode");
        String code = getPara("code");
        //双引号转义
        if (StringUtils.isNotEmpty(code)) code = StringEscapeUtils.unescapeHtml4(code);
        SendSmsMsg.sendSMS(phone, code, templateCode);
        setAttr("msg","发送成功");
        renderJson();
    }

}
